package dbops

import "log"

func ReadVideoDeletionRecord(count int)([]string,error)  {
	stmOut,err := dbConn.Prepare("SELECT video_id FROM video_del_rec LIMIT ?")
	var ids []string
	if err != nil {
		return ids,err
	}
	rows,err := stmOut.Query(count)
	if err != nil{
		log.Printf("Query VideoDeletionRecord Error :%v",err)
		return ids,err
	}

	for rows.Next(){
		var id string
		if err:=rows.Scan(&id);err!= nil{
			return ids,err
		}
		ids = append(ids,id)
	}
	defer stmOut.Close()
	return ids,nil
}

func DelVideoDeletionRecord(vid string) error{
	stmtDel,err :=dbConn.Prepare("DELETE FROM VIDEO_DEL_REC WHERE VIDEO_ID = ?")
	if err != nil{
		return err
	}
	_,err = stmtDel.Exec(vid)
	if err != nil {
		log.Printf("Deleting VideoDeltionRecord error %v",err)
		return err
	}
	defer stmtDel.Close()
	return nil
}